from typing import TypedDict, List


class RobotDict(TypedDict):  # 111111
    id: str
    username: str
    avatar: str


class User(TypedDict):
    id: str
    username: str
    avatar: str
    bot: bool
    union_openid: str
    union_user_account: str


class Member(TypedDict):
    user: User
    nick: str
    roles: List[str]
    joined_at: str


class UserPayload(TypedDict):
    id: str
    username: str
    bot: bool
    status: int
    avatar: str


class MessageRefPayload(TypedDict):
    message_id: str


class MessageAttachPayload(TypedDict):
    content_type: str
    filename: str
    height: int
    width: int
    id: str
    size: int
    url: str


class MessagePayload(TypedDict):
    author: UserPayload
    channel_id: str
    content: str
    guild_id: str
    id: str
    member: Member
    message_reference: MessageRefPayload
    mentions: List[UserPayload]
    attachments: List[MessageAttachPayload]
    seq: int
    seq_in_channel: str
    timestamp: str


class Attachment(TypedDict):
    url: str


class Thumbnail(TypedDict):
    url: str  # 图片地址


class EmbedField(TypedDict):
    name: str


class Embed(TypedDict, total=False):
    title: str  # 标题
    prompt: str  # 消息弹窗内容
    thumbnail: Thumbnail  # 缩略图
    fields: List[EmbedField]  # 消息创建时间


class ArkObjKv(TypedDict):
    key: str
    value: str


class ArkObj(TypedDict):
    obj_kv: List[ArkObjKv]


class ArkKv(TypedDict, total=False):
    key: str
    value: str
    obj: List[ArkObj]


class Ark(TypedDict):
    template_id: int
    kv: List[ArkKv]


class Reference(TypedDict):
    message_id: str
    ignore_get_message_error: bool


class MessageMarkdownParams(TypedDict):
    key: str
    values: List[str]


class MarkdownPayload(TypedDict, total=False):
    custom_template_id: str
    params: List[MessageMarkdownParams]
    content: str


class Media(TypedDict):
    file_uuid: str  # 文件ID
    file_info: str  # 文件信息，用于发消息接口的media字段使用
    ttl: int  # 有效期，标识剩余多少秒到期，到期后 file_info 失效，当等于 0 时，表示可长期使用


class Message(MessagePayload):
    edited_timestamp: str
    mention_everyone: str
    attachments: List[Attachment]
    embeds: List[Embed]
    ark: Ark
    message_reference: Reference
    markdown: MarkdownPayload
    # keyboard: KeyboardPayload
